package com.scau.phradmin.business.doctor.controller;

import com.scau.phradmin.business.doctor.service.DoctorService;
import com.scau.phradmin.domain.entity.Doctor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/doctor")
@RestController
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @GetMapping("/selectAll")
    public Object selectAll(@RequestParam("pages") int pages)
    {
        return doctorService.selectAll(pages);
    }

    @GetMapping("/selectById")
    public Object selectByTelephone(@RequestParam("telephone") String telephone)
    {
        return doctorService.selectByTelephone(telephone);
    }

    @PostMapping("/edit")
    public boolean edit(Doctor doctor){
        return doctorService.edit(doctor);
    }

    @PostMapping("/add")
    public boolean add(Doctor doctor){
        return doctorService.add(doctor);
    }

    @PostMapping("/delete")
    public boolean delete(@RequestParam("id") Long id){
        return doctorService.delete(id);
    }

    @PostMapping("/register")
    public Object register(Doctor doctor){
        return doctorService.register(doctor);
    }

    @PostMapping("/login")
    public Object login(@RequestParam("telephone")String telephone,@RequestParam("password")String passWord){
        return doctorService.login(telephone,passWord);
    }
}
